{include file="header.tpl"}

   <h1>{if $ticket.id == 0}New Ticket{else}Edit Ticket - {$ticket.id}{/if}</h1>
   
   <div id="content">
      
      {include file="flashes.tpl"}
   	<form id="frm_ticket" action="" method="post">
         
         <div class="hidden">
            <input type="hidden" id="created_user" name="created_user" value="{$ticket.created_user}" />
            <input type="hidden" id="created_date" name="created_date" value="{$ticket.created_date}" />
         </div>
         
   		<fieldset class="panel">
   			
   			<div>
   				<label for="title">Title:</label>
        			<input id="title" name="title" type="text" value="{$ticket.title}" />
        			{if $ticket.errors.title}<p class="error">{$ticket.errors.title}</p>{/if}
   	 		</div>
   			
   			<div class="group">
      			
      			<div>
      				<label for="ticket_status_id">Status:</label>
           			<select id="ticket_status_id" name="ticket_status_id">
                     <option value="">-- Select A Status --</option>
                     {foreach key=id item=desc from=$ticket_status}
                     <option value="{$id}"{if $id == $ticket.ticket_status_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.ticket_status_id}<p class="error">{$ticket.errors.ticket_status_id}</p>{/if}
      	 		</div>
      			
      			<div>
      				<label for="ticket_type_id">Type:</label>
           			<select id="ticket_type_id" name="ticket_type_id">
                     <option value="">-- Select A Type --</option>
                     {foreach key=id item=desc from=$ticket_type}
                     <option value="{$id}"{if $id == $ticket.ticket_type_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.ticket_type_id}<p class="error">{$ticket.errors.ticket_type_id}</p>{/if}
      	 		</div>
      			
      			<div>
      				<label for="assigned_user">Assigned To:</label>
           			<select id="assigned_user" name="assigned_user">
                     <option value="">-- Nobody --</option>
                     {foreach key=user_name item=display_name from=$users}
                     <option value="{$user_name}"{if $user_name == $ticket.assigned_user}{$spf.selected}{/if}>{$display_name}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.assigned_user}<p class="error">{$ticket.errors.assigned_user}</p>{/if}
      	 		</div>
      	 		
   			</div>
   			
   			<div class="group">
   			
      			<div>
      				<label for="component_id">Component:</label>
           			<select id="component_id" name="component_id">
                     <option value="">-- None --</option>
                     {foreach key=id item=desc from=$components}
                     <option value="{$id}"{if $id == $ticket.component_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.component_id}<p class="error">{$ticket.errors.component_id}</p>{/if}
      	 		</div>
      			
      			<div>
      				<label for="milestone_id">Milestone:</label>
           			<select id="milestone_id" name="milestone_id">
                     <option value="">-- None --</option>
                     {foreach key=id item=desc from=$milestones}
                     <option value="{$id}"{if $id == $ticket.milestone_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.milestone_id}<p class="error">{$ticket.errors.milestone_id}</p>{/if}
      	 		</div>
      			
   			</div>
   			
   			<div class="group">
   			
      			<div>
      				<label for="ticket_priority_id">Priority:</label>
           			<select id="ticket_priority_id" name="ticket_priority_id">
                     <option value="">-- None --</option>
                     {foreach key=id item=desc from=$ticket_priority}
                     <option value="{$id}"{if $id == $ticket.ticket_priority_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.ticket_priority_id}<p class="error">{$ticket.errors.ticket_priority_id}</p>{/if}
      	 		</div>
      			
      			<div>
      				<label for="ticket_severity_id">Severity:</label>
           			<select id="ticket_severity_id" name="ticket_severity_id">
                     <option value="">-- None --</option>
                     {foreach key=id item=desc from=$ticket_severity}
                     <option value="{$id}"{if $id == $ticket.ticket_severity_id}{$spf.selected}{/if}>{$desc}</option>
                     {/foreach}
      				</select>
           			{if $ticket.errors.ticket_severity_id}<p class="error">{$ticket.errors.ticket_severity_id}</p>{/if}
      	 		</div>
      			
      	 	</div>
   			
   			<div class="clear">
   				<label for="details">Details:</label>
        			<textarea id="details" name="details" rows="15">{$ticket.details}</textarea>
        			{if $ticket.errors.details}<p class="error">{$ticket.errors.details}</p>{/if}
   	 		</div>
   			
   		</fieldset>
   
   		<div class="button_bar">
   			<button type="submit" name="submit_frm_ticket" value="1">Submit</button>or <a href="{$spf.base_url}/tickets/{if !$ticket.id}browse/{$current_project.id}{else}view/{$ticket.id}{/if}">Cancel</a>
   		</div>
   		
   	</form>

      <div class="clear"></div>
      
   </div>

{include file="footer.tpl"}
